package section4;

import java.util.Scanner;

public class eighth{
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("请输入一个0~100的数：");
        int digit=input.nextInt();
		int number = (int)(Math.random()*100);
		int counter=0;
		int max=100;
		int min=0;
		for(;digit!=number&&counter<20;counter++) {
			if(digit>number) {
				System.out.println("你输入的数字偏大");
				if(max>digit) {
				  max=digit;
				}else {
					System.out.println("你输入的数字不在指定区间内，请重新输入");
				}
				System.out.println("请再输入一个"+min+"~"+max+"的数:");
				digit=input.nextInt();
			}
			else if(digit<number) {
				System.out.println("你输入的数字偏小");
				if(digit>min) {
				min=digit;
				}else {
					System.out.println("你输入的数字不在指定区间内，请重新输入");
				}
				System.out.println("请再输入一个"+min+"~"+max+"的数:");
				digit=input.nextInt();
			}
		}
		if(digit==number) {
			System.out.println("恭喜你猜对了，正确数字是："+digit);
		}
		if(counter==1) {
			System.out.println("你太有才了");
		}
		else if(counter>=2&&counter<=6) {
			System.out.println("这么快就猜出来了，很聪明么！");
		}
		else {
			System.out.println("猜了半天才猜出来，小同志，尚需努力啊！");
		}
	}
}